<template>
    <div class="close">
        <el-container>
            <el-header class="title">
                <i class="el-icon-s-order">案件信息</i>
            </el-header>

            <el-table style="width: 95%;margin: 0 auto" :border="true" :data="lawList">
                <el-table-column label="案号" prop="caseNo"></el-table-column>
                <el-table-column label="案件类别" prop="caseTypeName"></el-table-column>
                <el-table-column label="案由" prop="caseCause"></el-table-column>
                <el-table-column label="委托人" prop="caseWtr"></el-table-column>
                <el-table-column label="承办律师" prop="caseAttorney"></el-table-column>
                <el-table-column label="收案时间" prop="collectionTime"></el-table-column>
                <el-table-column label="结案" prop="caseNo">
                    <template slot-scope="scope">
                        {{scope.row.caseNo == 'Y' ? '已结案':'未结案'}}
                    </template>
                </el-table-column>
                <el-table-column label="代理费(元)" prop="caseAgencyfee"></el-table-column>
                <el-table-column label="收案审批" prop="caseApproveStatus" :formatter="formatLawStatus"></el-table-column>
            </el-table>
        </el-container>

        <el-divider></el-divider>

        <el-container>
            <el-header class="title">
                <i class="el-icon-document-copy">文书信息</i>
            </el-header>

            <el-table style="width: 95%;margin: 0 auto" :border="true" :data="sealApplyforList">
                <el-table-column label="案号" prop="caseNo"></el-table-column>
                <el-table-column label="领用人" prop="applyforRecipient"></el-table-column>
                <el-table-column label="收函方/委托人" prop="sendPerson"></el-table-column>
                <el-table-column label="用印事项" prop="applyforUsingTheItem"></el-table-column>
                <el-table-column label="领用日期" prop="applyforReceive"></el-table-column>
                <el-table-column label="审批状态" prop="applyforApprovalStatus" :formatter="formatSealStatus"></el-table-column>
            </el-table>
        </el-container>
    </div>
</template>

<script>
    import CaseLawService from '../../../model/gs/CaseLawService.js'
    import {CaseSealApplyforService} from "../../../model/gs/CaseSealApplyforService";

    const caseLawService = CaseLawService.getInstance()
    const caseSealApplyforService = CaseSealApplyforService.getInstance()

    export default {
        props:['caseid','active'],
        data() {
            return {
                lawList:[],
                sealApplyforList:[]
            }
        },
        methods:{
            //通过id查询案件的方法
            getLawById(){
                caseLawService.getById(this.caseid).then(response => {
                    if(response.data.code === 0){
                        const array = []
                        array.push(response.data.data)
                        this.lawList = array
                    }
                })
            },
            //通过id查询文书的方法
            getCaseSealApplyforList(){
                caseSealApplyforService.getByCaseLaw(this.caseid).then(response => {
                    if(response.data.code === 0){
                        this.sealApplyforList = response.data.data
                    }
                })
            },
            //格式化审批状态的方法
            formatLawStatus(row){
                console.log(row.caseApproveStatus)
                if(row.caseApproveStatus == '1'){
                    return '审批中'
                } else if (row.caseApproveStatus == '2') {
                    return '审批通过'
                } else {
                    return '审批不通过'
                }
            },
            //格式化文书审批状态的方法
            formatSealStatus(row){
                if(row.applyforApprovalStatus == '1'){
                    return '审批中'
                } else if (row.applyforApprovalStatus == '2') {
                    return '审批通过'
                } else {
                    return '审批不通过'
                }
            }
        },
        watch:{
            active:{
                handler(){
                    if(this.active == 5){
                        this.getLawById()
                        this.getCaseSealApplyforList()
                    }
                }
            }
        }
    }
</script>

<style scoped>
    .close{
        width: 100%;
    }
    .title{
        font-size: 20px;
    }
</style>